import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* 静态路由 */
export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/editPwd',
    name: 'editPwd',
    component: Layout,
    hidden: true
  },
  {
    path: '/alipay',
    name: 'alipay',
    meta: { title: '支付', icon: 'alipay' },
    component:() => import('@/views/alipay/index')
  },
  {
    path: '/preview',
    name: 'preview',
    component: ()=>import('@/views/preview/index'),
    hidden: true
  },
  {
    path: '/recharge',
    name: 'recharge',
    component: () => import('@/views/recharge/index'),
    hidden: true
  },
  {
    path: '/rechargeCode',
    name: 'rechargeCode',
    component: () => import('@/views/recharge/code'),
    hidden: true
  },
  {
    path: '/rechargeSuccess',
    name: 'rechargeSuccess',
    component: () => import('@/views/recharge/success'),
    hidden: true
  },
  {
    path: '/previewOther',
    name: 'previewOther',
    component: ()=>import('@/views/preview/other'),
    hidden: true
  },
  {
    path: '/trans',
    component: () => import('@/views/trans'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/trans',
    hidden: true
  },
  {
    path: '/logisticsH5',
    component: () => import('@/views/skipPage/logisticsInfo/index.vue'),
    hidden: true
  },
  {
    path: '/goodsDetails',
    component: () => import('@/views/skipPage/goodsDetails/index.vue'),
    hidden: true
  }
]

/* 动态路由 */
export const asyncRoutes = [
  {
    path: '/xcxPos',
    name: 'xcxPos',
    component: Layout,
    redirect: '/xcxPos/home',
    meta: { title: '推荐位管理', icon: 'position' },
    children: [
      {
        path: 'home',
        name: 'xcxPosHome',
        component: () => import('@/views/xcxPos/home/index'),
        meta: { title: '首页推荐位', icon: '' }
      },
      {
        path: 'preview',
        name: 'xcxPosPreview',
        hidden: true,
        component: () => import('@/views/xcxPos/home/preview'),
        meta: {
          title: '小程序预览',
          icon: '',
          activeMenu: '/xcxPos/home',
          parentTitle: '首页推荐位',
          parentRouteName: 'xcxPosHome'
        }
      }
    ]
  },
  {
    path: '/webConfig',
    name: 'webConfig',
    component: Layout,
    redirect: '/webConfig/category',
    meta: { title: 'PC端配置', icon: 'config' },
    children: [
      {
        path: 'category',
        name: 'webConfigCategory',
        component: () => import('@/views/web/category/index'),
        meta: { title: '商品首页品类板块', icon: '' }
      },
      {
        path: 'category-add/:type/:editId?',
        name: 'webConfigCategoryAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/web/category/add'),
        meta: {
          title: '添加品类模板',
          icon: '',
          activeMenu: '/webConfig/category',
          parentTitle: '商品首页品类板块',
          parentRouteName: 'webConfigCategory'
        }
      },
      {
        path: 'show',
        name: 'webConfigShow',
        component: () => import('@/views/web/show/index'),
        meta: { title: '商品首页展示板块', icon: '' }
      },
      {
        path: 'show-add/:editId?',
        name: 'webConfigShowAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/web/show/add'),
        meta: {
          title: '添加板块',
          icon: '',
          activeMenu: '/webConfig/show',
          parentTitle: '商品首页展示板块',
          parentRouteName: 'webConfigShow'
        }
      }
    ]
  },
  {
    path: '/article',
    name: 'article',
    component: Layout,
    redirect: '/article/platform',
    meta: { title: '文章信息管理', icon: 'info' },
    children: [
      {
        path: 'platform',
        name: 'articlePlatform',
        component: () => import('@/views/article/index'),
        meta: { title: '文章信息列表', icon: '' }
      },
      {
        path: 'platform-add/:type/:editId?',
        name: 'articlePlatformAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/article/add'),
        meta: {
          title: '平台发布文章',
          icon: '',
          activeMenu: '/article/platform',
          parentTitle: '平台文章列表',
          parentRouteName: 'articlePlatform'
        }
      },
      {
        path: 'info',
        name: 'articleInfoConfig',
        component: () => import('@/views/web/info/index'),
        meta: { title: '信息配置', icon: '' }
      },
      {
        path: 'info-add/:parentId?/:editId?',
        name: 'articleInfoConfigAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/web/info/add'),
        meta: {
          title: '添加信息',
          icon: '',
          activeMenu: '/webConfig/info',
          parentTitle: '信息配置',
          parentRouteName: 'articleInfoConfig'
        }
      }
    ]
  },

  {
    path: '/delivery',
    name: 'delivery',
    component: Layout,
    redirect: '/delivery/platform',
    meta: { title: '数据看板', icon: 'el-icon-s-order' },
    children: [
      {
        path: 'platform',
        name: 'deliveryPlatform',
        component: () => import('@/views/delivery/index'),
        meta: { title: '数据看板', icon: '' }
      },
      {
        path: 'overduechart',
        name: 'deliveryoverdue',
        component: () => import('@/views/delivery/overduechart'),
        meta: { title: '逾期客户', icon: '' }
      }

    ]
  },

  {
    path: '/recommend',
    name: 'recommend',
    component: Layout,
    redirect: '/recommend/banner',
    meta: { title: 'PC商城推荐位管理', icon: 'position' },
    children: [
      {
        path: 'banner',
        name: 'recommendBanner',
        component: () => import('@/views/recommend/banner/index'),
        meta: { title: '商城banner设置', icon: '' }
      },
      {
        path: 'category',
        name: 'recommendCategory',
        component: () => import('@/views/recommend/category/index'),
        meta: { title: '首页品类商品推荐', icon: '' }
      },
      {
        path: 'activity',
        name: 'recommendActivity',
        component: () => import('@/views/recommend/activity/index'),
        meta: { title: '首页活动板块', icon: '' }
      },
      {
        path: 'custom',
        name: 'recommendCustom',
        component: () => import('@/views/recommend/custom/index'),
        meta: { title: '首页自定义板块', icon: '' }
      }
    ]
  },
  {
    path: '/account',
    name: 'account',
    component: Layout,
    redirect: '/account/list',
    meta: { title: '账号管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'accountList',
        component: () => import('@/views/system/account/index'),
        meta: { title: '账号列表', icon: '' }
      }
    ]
  },
  {
    path: '/permission',
    name: 'permission',
    component: Layout,
    redirect: '/permission/role',
    meta: { title: '权限管理', icon: 'permission' },
    children: [
      {
        path: 'role',
        name: 'permissionRole',
        component: () => import('@/views/system/role/index'),
        meta: { title: '角色列表', icon: '' }
      }
    ]
  },
  {
    path: '/menu',
    name: 'menu',
    component: Layout,
    redirect: '/menu/list',
    meta: { title: '菜单管理', icon: 'set' },
    children: [
      {
        path: 'list',
        name: 'menuList',
        component: () => import('@/views/system/menu/index'),
        meta: { title: '菜单列表', icon: '' }
      }
    ]
  },
  {
    path: '/supplier',
    name: 'supplier',
    component: Layout,
    redirect: '/supplier/list',
    meta: { title: '供应商管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'supplierList',
        component: () => import('@/views/supplier'),
        meta: { title: '供应商列表', icon: '', keepAlive: true }
      },
      {
        path: 'supplierPromoterList',
        name: 'supplierPromoterList',
        component: () => import('@/views/promoter/promoterList'),
        meta: {
          title: '推广员列表',
          icon: '',
          activeMenu: '/supplier/supplierPromoterList',
          parentTitle: '供应商列表',
          parentRouteName: 'supplierList'
        }
      },
      {
        path: 'view/:viewId/:toEdit?',
        name: 'supplierView',
        props: true,
        hidden: true,
        component: () => import('@/views/supplier/view'),
        meta: {
          title: '供应商信息',
          icon: '',
          activeMenu: '/supplier/list',
          parentTitle: '供应商列表',
          parentRouteName: 'supplierList'
        }
      }
    ]
  },
  {
    path: '/merchant',
    name: 'merchant',
    component: Layout,
    redirect: '/merchant/list',
    meta: { title: '代理商管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'merchantList',
        component: () => import('@/views/merchant'),
        meta: { title: '代理商列表', icon: '' }
      }
    ]
  },
  {
    path: '/real',
    name: 'real',
    component: Layout,
    redirect: '/real/list',
    meta: { title: '租户管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'realList',
        component: () => import('@/views/real'),
        meta: { title: '租户列表', icon: '', keepAlive: true }
      },
      {
        path: 'view/:viewId/:toEdit?',
        name: 'realView',
        props: true,
        hidden: true,
        component: () => import('@/views/real/view'),
        meta: {
          title: '租户信息',
          icon: '',
          activeMenu: '/real/list',
          parentTitle: '租户列表',
          parentRouteName: 'realList'
        }
      }
    ]
  },
  {
    path: '/goods',
    name: 'goods',
    component: Layout,
    redirect: '/goods/list',
    meta: { title: '商品管理', icon: 'product' },
    children: [
      {
        path: 'list',
        name: 'goodsList',
        component: () => import('@/views/goods/index'),
        meta: { title: '商品列表', icon: '', keepAlive: true }
      },
      {
        path: 'editBase/:editId',
        name: 'goodsBaseEdit',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/editBase'),
        meta: {
          title: '编辑商品信息',
          icon: '',
          activeMenu: '/goods/list',
          parentTitle: '商品列表',
          parentRouteName: 'goodsList'
        }
      },
      {
        path: 'mealInfo/:goodsId',
        name: 'goodsMealInfo',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/mealList'),
        meta: {
          title: '套餐信息',
          icon: '',
          activeMenu: '/goods/list',
          parentTitle: '商品列表',
          parentRouteName: 'goodsList'
        }
      },
      {
        path: 'success/:goodsId',
        name: 'goodsSuccess',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/success'),
        meta: {
          title: '编辑商品',
          icon: '',
          activeMenu: '/goods/list',
          parentTitle: '商品列表',
          parentRouteName: 'goodsList'
        }
      },
      {
        path: 'editMeal/:goodsId/:editId',
        name: 'goodsMealEdit',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/editMeal'),
        meta: {
          title: '编辑套餐',
          icon: '',
          activeMenu: '/goods/list',
          parentTitle: '商品列表',
          parentRouteName: 'goodsList'
        }
      },
      {
        path: 'view/:goodsId',
        name: 'goodsView',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/view'),
        meta: {
          title: '查看商品',
          icon: '',
          activeMenu: '/goods/list',
          parentTitle: '商品列表',
          parentRouteName: 'goodsList'
        }
      }
    ]
  },
  {
    path: '/audit',
    name: 'audit',
    component: Layout,
    redirect: '/audit/category',
    meta: { title: '审核管理', icon: 'audit' },
    children: [
      {
        path: 'category',
        name: 'auditCategory',
        component: () => import('@/views/audit/category/index'),
        meta: { title: '品类审核', icon: '' }
      },
      {
        path: 'product',
        name: 'auditGoods',
        component: () => import('@/views/audit/goods/index'),
        meta: { title: '商品审核', icon: '', keepAlive: true }
      },
      {
        path: 'offGoods',
        name: 'auditOffGoods',
        component: () => import('@/views/audit/goods/off'),
        meta: { title: '商品下架审核', icon: '', keepAlive: true }
      },
      {
        path: 'wong',
        name: 'auditoWong',
        component: () => import('@/views/audit/wong/index'),
        meta: { title: '征信审核', icon: '', keepAlive: true }
      },
      {
        path: 'view/:goodsId',
        name: 'auditViewGoods',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/view'),
        meta: {
          title: '查看商品',
          icon: '',
          activeMenu: '/audit/product',
          parentTitle: '商品审核',
          parentRouteName: 'auditGoods'
        }
      },
      {
        path: 'check/:goodsId',
        name: 'auditCheckGoods',
        hidden: true,
        props: true,
        component: () => import('@/views/goods/view'),
        meta: {
          title: '查看商品',
          icon: '',
          activeMenu: '/audit/offGoods',
          parentTitle: '商品下架审核',
          parentRouteName: 'auditCheckGoods'
        }
      },
      {
        path: 'supplier',
        name: 'auditSupplier',
        component: () => import('@/views/audit/supplier/index'),
        meta: { title: '供应商审核', icon: '', keepAlive: true }
      },
      {
        path: 'supplierView/:viewId/:toEdit?',
        name: 'auditSupplierView',
        props: true,
        hidden: true,
        component: () => import('@/views/audit/supplier/view'),
        meta: {
          title: '查看供应商资料',
          icon: '',
          activeMenu: '/audit/supplier',
          parentTitle: '供应商审核',
          parentRouteName: 'auditSupplier'
        }
      }
    ]
  },
  {
    path: '/finance',
    name: 'finance',
    component: Layout,
    redirect: '/finance/billing',
    meta: { title: '财务审核', icon: 'refund' },
    children: [
      {
        path: 'billing',
        name: 'financeBilling',
        component: () => import('@/views/finance/billing/index'),
        meta: { title: '账单结算', icon: '' }
      },
      {
        path: 'payBill',
        name: 'financePayBill',
        component: () => import('@/views/finance/payBill/index'),
        meta: { title: '花呗账单结算', icon: '' }
      },
      {
        path: 'refundAudit',
        name: 'financeRefund',
        component: () => import('@/views/finance/refundAudit/index'),
        meta: { title: '退款审核', icon: '' }
      },
      {
        path: 'details/:orderId',
        name: 'financeRefundDetail',
        hidden: true,
        props: true,
        component: () => import('@/views/finance/refundAudit/details'),
        meta: {
          title: '退款审核',
          icon: '',
          activeMenu: '/finance/refundAudit',
          parentTitle: '退款审核',
          parentRouteName: 'finance'
        }
      },
      {
        path: 'withdrawal',
        name: 'financeWithdrawal',
        component: () => import('@/views/finance/withdrawal/index'),
        meta: { title: '提现审核', icon: '' }
      },
      {
        path: 'withdrawalList',
        name: 'financeWithdrawalList',
        component: () => import('@/views/finance/withdrawal/userIndex'),
        meta: { title: '用户提现审核', icon: '' }
      }
      // {
      //   path: "view/:goodsId",
      //   name: "auditViewGoods",
      //   hidden: true,
      //   props: true,
      //   component: () => import("@/views/goods/view"),
      //   meta: {
      //     title: "查看商品",
      //     icon: "",
      //     activeMenu: "/audit/product",
      //     parentTitle: "商品审核",
      //     parentRouteName: "auditGoods",
      //   },
      // },
    ]
  },
  {
    path: '/info',
    name: 'info',
    component: Layout,
    redirect: '/info/list',
    meta: { title: '基础信息管理', icon: 'category' },
    children: [
      {
        path: 'list',
        name: 'infoCategoryList',
        component: () => import('@/views/info/list/index'),
        meta: { title: '品类列表', icon: '' }
      },
      {
        path: 'custom',
        name: 'infoDefineForm',
        component: () => import('@/views/info/custom/index'),
        meta: { title: '定义表单项', icon: '' }
      },
      {
        path: 'source',
        name: 'infoOrderSource',
        component: () => import('@/views/info/source/index'),
        meta: { title: '订单来源', icon: '' }
      }
    ]
  },
  {
    path: '/lease',
    name: 'lease',
    component: Layout,
    redirect: '/lease/user',
    meta: { title: '租赁宝管理', icon: 'order' },
    children: [
      {
        path: 'user',
        name: 'leaseUser',
        component: () => import('@/views/lease/user'),
        meta: { title: '订单用户信息', icon: '' }
      },
      {
        path: 'order',
        name: 'leaseOrder',
        component: () => import('@/views/lease/order'),
        meta: { title: '订单信息', icon: '' }
      },
      {
        path: 'product',
        name: 'leaseGoods',
        component: () => import('@/views/lease/goods'),
        meta: { title: '订单商品信息', icon: '' }
      },
      {
        path: 'logistics',
        name: 'leaseLogistics',
        component: () => import('@/views/lease/logistics'),
        meta: { title: '订单物流信息', icon: '' }
      },
      {
        path: 'promise',
        name: 'leasePromise',
        component: () => import('@/views/lease/promise'),
        meta: { title: '订单承诺信息', icon: '' }
      },
      {
        path: 'appoint',
        name: 'leaseAppoint',
        component: () => import('@/views/lease/appoint'),
        meta: { title: '订单履约信息', icon: '' }
      },
      {
        path: 'financing',
        name: 'leaseFinanc',
        component: () => import('@/views/lease/financing'),
        meta: { title: '订单查询', icon: '' }
      },
      {
        path: 'check/:orderNo',
        name: 'leaseCheckFinanc',
        hidden: true,
        props: true,
        component: () => import('@/views/lease/child/financDetail'),
        meta: {
          title: '租赁宝订单详情',
          icon: '',
          activeMenu: '/lease/financing',
          parentTitle: '订单查询',
          parentRouteName: 'leaseFinanc'
        }
      }
    ]
  },
  {
    path: '/popularize',
    name: 'popularize',
    component: Layout,
    redirect: '/popularize/classify',
    meta: { title: '商品推广管理', icon: 'audit' },
    children: [
      {
        path: 'classify',
        name: 'popularizeClassify',
        component: () => import('@/views/popularize/classify'),
        meta: { title: '商品推广分类列表', icon: '' }
      },
      {
        path: 'list',
        name: 'popularizeList',
        component: () => import('@/views/popularize/list'),
        meta: { title: '商品推广列表', icon: '' }
      }
    ]
  },
  {
    path: '/order',
    name: 'order',
    component: Layout,
    redirect: '/order/list',
    meta: { title: '订单管理', icon: 'order' },
    children: [
      {
        path: 'list',
        name: 'orderList',
        component: () => import('@/views/order/list'),
        meta: { title: '订单列表', icon: '' }
      },
      {
        path: 'index',
        name: 'orderbook',
        component: () => import('@/views/order/index'),
        meta: { title: '逾期列表', icon: '' }
      },
      {
        path: 'orderRepaymentList',
        name: 'orderRepaymentList',
        component: () => import('@/views/order/orderRepaymentList'),
        meta: { title: '已还款列表', icon: '' }
      },
      {
        path: 'orderError',
        name: 'orderError',
        component: () => import('@/views/order/orderError'),
        meta: { title: '异常列表', icon: '' }
      },
      {
        path: 'statement ',
        name: 'orderstatement',
        component: () => import('@/views/order/statement'),
        meta: { title: '账单日列表', icon: '' }
      },
      {
        path: 'refundList',
        name: 'orderrefundList',
        component: () => import('@/views/order/refundlist'),
        meta: { title: '退款订单列表', icon: '' }
      },
      {
        path: 'promoterList',
        name: 'orderPromoter',
        component: () => import('@/views/order/promoterList'),
        meta: { title: '推广员订单', icon: '' }
      },
      // {
      //   path: 'buyout',
      //   name: 'orderBuyout',
      //   component: () => import('@/views/order/buyout'),
      //   meta: { title: '买断订单', icon: '' }
      // },
      // {
      //   path: 'unpay',
      //   name: 'orderUnpay',
      //   component: () => import('@/views/order/unpay'),
      //   meta: { title: '签约待支付订单', icon: '' }
      // },
      // {
      //   path: 'relet',
      //   name: 'orderRelet',
      //   component: () => import('@/views/order/relet'),
      //   meta: { title: '续租订单', icon: '' }
      // },
      // {
      //   path: 'risk',
      //   name: 'orderRisk',
      //   component: () => import('@/views/order/risk'),
      //   meta: { title: '风控订单', icon: '' }
      // }
    ]
  },
  {
    path: '/refund',
    name: 'refund',
    component: Layout,
    redirect: '/refund/list',
    meta: { title: '退款管理', icon: 'refund' },
    children: [
      {
        path: 'list',
        name: 'refundList',
        component: () => import('@/views/refund/list'),
        meta: { title: '仅退款列表', icon: '' }
      },
      {
        path: 'refundDetails/:id',
        name: 'refundDetail',
        hidden: true,
        props: true,
        component: () => import('@/views/refund/refundDetails'),
        meta: {
          title: '退款详情',
          icon: '',
          activeMenu: '/refund/list',
          parentTitle: '仅退款列表',
          parentRouteName: 'refund'
        }
      }
    ]
  },
  // {
  //   path: '/overdue',
  //   name: 'overdue',
  //   component: Layout,
  //   redirect: '/overdue/list',
  //   meta: { title: '逾期管理', icon: 'overdue' },
  //   children: [
  //     {
  //       path: 'list',
  //       name: 'overdueList',
  //       component: () => import('@/views/overdue/index'),
  //       meta: { title: '逾期列表', icon: '' }
  //     }
  //   ]
  // },
  {
    path: '/thirdData',
    name: 'thirdData',
    component: Layout,
    redirect: '/thirdData/message',
    meta: { title: '第三方数据', icon: 'data' },
    children: [
      {
        path: 'message',
        name: 'thirdDataMessage',
        component: () => import('@/views/thirdData/message'),
        meta: { title: '短信使用列表', icon: '' }
      },
      // {
      //   path: 'risk',
      //   name: 'thirdDataRisk',
      //   component: () => import('@/views/thirdData/risk'),
      //   meta: { title: '风控使用列表', icon: '' }
      // },
      {
        path: 'rickwong',
        name: 'thirdDataRickwong',
        component: () => import('@/views/thirdData/rickWong'),
        meta: { title: '征信使用列表', icon: '' }
      },
      {
        path: 'policy',
        name: 'thirdDataPolicy',
        component: () => import('@/views/thirdData/policy'),
        meta: { title: '保险数据', icon: '' }
      },
      {
        path: 'sendMessage',
        name: 'thirdDataSendMessage',
        component: () => import('@/views/thirdData/sendMessage'),
        meta: { title: '发送短信系统', icon: '' }
      }
    ]
  },
  {
    path: '/complaint',
    name: 'complaint',
    component: Layout,
    redirect: '/complaint/list',
    meta: { title: '投诉与建议', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'complaintList',
        component: () => import('@/views/complaint/index'),
        meta: { title: '投诉列表', icon: '' }
      },
      {
        path: 'complaintDetails/:id',
        name: 'complaintDetail',
        hidden: true,
        props: true,
        component: () => import('@/views/complaint/complaintDetails'),
        meta: {
          title: '查看详情',
          icon: '',
          activeMenu: '/complaint/list',
          parentTitle: '投诉列表',
          parentRouteName: 'complaint'
        }
      }
    ]
  },
  {
    path: '/bill',
    name: 'bill',
    component: Layout,
    redirect: '/bill/list',
    meta: { title: '账单管理', icon: 'bill' },
    children: [
      {
        path: 'list',
        name: 'billList',
        component: () => import('@/views/bill/index'),
        meta: { title: '订单财务列表', icon: '' }
      },
      {
        path: 'bill',
        name: 'billBill',
        component: () => import('@/views/bill/bill'),
        meta: { title: '账单财务列表', icon: '' }
      },
      {
        path: 'hb',
        name: 'billHb',
        component: () => import('@/views/bill/hb'),
        meta: { title: '花呗分期账单', icon: '' }
      },
      {
        path: 'device',
        name: 'billDevice',
        component: () => import('@/views/bill/device'),
        meta: { title: '设备分期导出', icon: '' }
      },
      {
        path: 'payment',
        name: 'billPayment',
        component: () => import('@/views/bill/payment'),
        meta: { title: '回款导出', icon: '' }
      }
    ]
  },
  {
    path: '/overdue',
    name: 'overdue',
    component: Layout,
    redirect: '/overdue/list',
    meta: { title: '逾期管理', icon: 'overdue' },
    children: [
      {
        path: 'list',
        name: 'overdueList',
        component: () => import('@/views/overdue/index'),
        meta: { title: '逾期列表', icon: '' }
      }
    ]
  },
  {
    path: '/reconciliation',
    name: 'reconciliation',
    component: Layout,
    redirect: '/reconciliation/withdrawal',
    meta: { title: '对账中心', icon: 'bill' },
    children: [
      {
        path: 'flow',
        name: 'reconciliationFlow',
        component: () => import('@/views/reconciliation/flow'),
        meta: { title: '对账流水', icon: '' }
      },
      {
        path: 'withdrawal',
        name: 'reconciliationWithdrawal',
        component: () => import('@/views/reconciliation/withdrawal'),
        meta: { title: '提现记录', icon: '' }
      },
      {
        path: 'userWithdrawal',
        name: 'reconciliationWithdrawalList',
        component: () => import('@/views/reconciliation/userWithdrawal'),
        meta: { title: '用户提现记录', icon: '' }
      }
    ]
  },
  {
    path: '/nine',
    name: 'nine',
    component: Layout,
    redirect: '/nine/office',
    meta: { title: '10大分类管理', icon: 'position' },
    children: [
      {
        path: 'mobile',
        name: 'nineMobile',
        component: () => import('@/views/nine/index'),
        meta: { title: '苹果手机', icon: '' }
      },
      {
        path: 'anmobile',
        name: 'nineMobileAn',
        component: () => import('@/views/nine/index'),
        meta: { title: '安卓手机', icon: '' }
      },
      {
        path: 'office',
        name: 'nineOffice',
        component: () => import('@/views/nine/index'),
        meta: { title: '办公设备', icon: '' }
      },
      {
        path: 'computer',
        name: 'nineComputer',
        component: () => import('@/views/nine/index'),
        meta: { title: '电脑设备', icon: '' }
      },
      {
        path: 'health',
        name: 'nineHealth',
        component: () => import('@/views/nine/index'),
        meta: { title: '智能穿戴', icon: '' }
      },
      {
        path: 'electric',
        name: 'nineElectric',
        component: () => import('@/views/nine/index'),
        meta: { title: '大牌平板', icon: '' }
      },
      {
        path: 'energy',
        name: 'nineEnergy',
        component: () => import('@/views/nine/index'),
        meta: { title: '游戏设备', icon: '' }
      },
      {
        path: 'camera',
        name: 'nineCamera',
        component: () => import('@/views/nine/index'),
        meta: { title: '大牌耳机', icon: '' }
      },
      {
        path: 'game',
        name: 'nineGame',
        component: () => import('@/views/nine/index'),
        meta: { title: '游戏掌机', icon: '' }
      },
      {
        path: 'home',
        name: 'nineHome',
        component: () => import('@/views/nine/index'),
        meta: { title: '智能手表', icon: '' }
      }
    ]
  },
  {
    path: '/activity',
    name: 'activity',
    component: Layout,
    redirect: '/activity/hb',
    meta: { title: '活动专区管理', icon: 'position' },
    children: [
      {
        path: 'hb',
        name: 'activityHb',
        component: () => import('@/views/nine/index'),
        meta: { title: '花呗专区', icon: '' }
      },
      {
        path: 'hot',
        name: 'activityHot',
        component: () => import('@/views/nine/index'),
        meta: { title: '热租爆品', icon: '' }
      },
      {
        path: 'short',
        name: 'activityShort',
        component: () => import('@/views/nine/index'),
        meta: { title: '短租精选', icon: '' }
      },
      {
        path: 'rent',
        name: 'activityRent',
        component: () => import('@/views/nine/index'),
        meta: { title: '租完即送', icon: '' }
      }
    ]
  },
  {
    path: '/h5Config',
    name: 'h5Config',
    component: Layout,
    redirect: '/h5Config/category',
    meta: { title: 'H5端配置', icon: 'audit' },
    children: [
      {
        path: 'category',
        name: 'h5ConfigCategory',
        component: () => import('@/views/h5/category/index'),
        meta: { title: '首页品类板块', icon: '' }
      },
      {
        path: 'categoryAdd/:type/:editId?',
        name: 'h5ConfigCategoryAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/h5/category/add'),
        meta: {
          title: '添加品类',
          icon: '',
          activeMenu: '/h5Config/category',
          parentTitle: '首页品类板块',
          parentRouteName: 'h5ConfigCategory'
        }
      },
      {
        path: 'show',
        name: 'h5ConfigShow',
        component: () => import('@/views/h5/show/index'),
        meta: { title: '首页展示板块', icon: '' }
      },
      {
        path: 'showAdd/:type/:editId?',
        name: 'h5ConfigShowAdd',
        hidden: true,
        props: true,
        component: () => import('@/views/h5/show/add'),
        meta: {
          title: '添加板块',
          icon: '',
          activeMenu: '/h5Config/show',
          parentTitle: '首页展示板块',
          parentRouteName: 'h5ConfigShow'
        }
      }
    ]
  },
  {
    path: '/h5Recommend',
    name: 'h5Recommend',
    component: Layout,
    redirect: '/h5Recommend/banner',
    meta: { title: 'H5端推荐位管理', icon: 'position' },
    children: [
      {
        path: 'banner',
        name: 'h5RecommendBanner',
        component: () => import('@/views/h5/banner/index'),
        meta: { title: '商城banner设置', icon: '' }
      },
      {
        path: 'activity',
        name: 'h5RecommendActivity',
        component: () => import('@/views/h5/activity/index'),
        meta: { title: '首页活动板块', icon: '' }
      },
      {
        path: 'custom',
        name: 'h5RecommendCustom',
        component: () => import('@/views/h5/custom/index'),
        meta: { title: '首页自定义板块', icon: '' }
      }
    ]
  },
  {
    path: '/h5Spread',
    name: 'h5Spread',
    component: Layout,
    redirect: '/h5Spread/spread',
    meta: { title: 'H5端商品推广管理', icon: 'position' },
    children: [
      {
        path: 'spreadClassify',
        name: 'h5SpreadClassify',
        component: () => import('@/views/h5/spread/spreadClassify/index'),
        meta: { title: '商品推广分类列表', icon: '' }
      },
      {
        path: 'spreadList',
        name: 'h5SpreadList',
        component: () => import('@/views/h5/spread/spreadList/index'),
        meta: { title: '商品推广列表', icon: '' }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () =>
  new Router({
    mode: 'history', // require service support
    scrollBehavior(to, from, savedPosition) {
      if (savedPosition) {
        return savedPosition
      } else {
        return { x: 0, y: 0 }
      }
    },
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
